# Natural Language Toolkit: General Bitext Model
#
# Copyright (C) 2001-2010 NLTK Project
# URL: <http://www.nltk.org/>
# For license information, see LICENSE.TXT

"""
This is the start of a different approach to alignment, which is intended to generalize
to phrasal alignments (even when phrases are non-contiguous).
"""


class Segmentation(list):
    """
    Segmentation object.  Indicates extents in time-series data using
    offsets.
    
        >>> Segmentation([(0,3), (4, 5), (6, 10)], "scheme:identifier")

    """
    
    def __init__(self, tuples, uri):
        list.__init__(self, tuples)
        self._uri = uri

class Alignment(list):
    pass




class Bitext(list):
    """
    Bitext object.  Encapsulates a sequence of items in the source language
    and an C{Alignment} with another sequence of items in a reference language.
    """
    
    def __init__(self, words, reference, alignment):
        """
        Initialize a new C{Bitext}.
        
        @param words: source language words
        @type words: C{list} of C{str}
        @param reference: reference language words
        @type reference: C{list} of C{str}
        @param alignment: the word-level alignments between the source
            and reference language
        @type alignment: C{Alignment}
        """
        list.__init__(self, words)
        if not isinstance(alignment, Alignment):
            alignment = Alignment(alignment)
        self._reference = reference
        self._alignment = alignment
    
    def reference(self):
        return self._reference
    
    def alignment(self):
        return self._alignment

    def __repr__(self):
        """
        @return: A string representation for this C{Bitext}.
        @rtype: C{string}
        """
        return "Bitext(%s, %r, %r)" % (list.__repr__(self), self._reference, self._alignment)
    
